package ruifeng.zcj.dig.groble;

import java.util.HashMap;

import ruifeng.zcj.dig.ui.assessment.AssessmentFragment;
import ruifeng.zcj.dig.ui.forum.ForumFragment;
import ruifeng.zcj.dig.ui.home.HomeFragment;
import ruifeng.zcj.dig.ui.shopping.ShoppingFragment;
import ruifeng.zcj.dig.ui.vehicle.VehicleFragment;
import ruifeng.zcj.mybase.base.BaseFragment;

/**
 * Created by Administrator on 2016/8/16 0016.
 */
public class FragmentFactory {
    // 保存Fragment集合,方便复用
    private static HashMap<Integer, BaseFragment> sFragmentMap = new HashMap<Integer, BaseFragment>();
    // 根据指针位置,生产相应的Fragment
    public static BaseFragment createFragment(int position) {
        BaseFragment fragment = sFragmentMap.get(position);
        if (fragment == null) {
            switch (position) {
                case 0:
                    fragment = new HomeFragment();
                    break;
                case 1:
                    fragment = new ShoppingFragment();
                    break;
                case 2:
                    fragment = new ForumFragment();
                    break;
                case 3:
                    fragment = new AssessmentFragment();
                    break;
                case 4:
                    fragment = new VehicleFragment();
                    break;
                case 5:
                   // fragment = new CategoryFragment();
                    break;
                default:
                    break;
            }
            sFragmentMap.put(position, fragment);
        }
        return fragment;
    }
}
